package com.young.monitor.web;

import com.young.common.util.Result;
import com.young.interfaces.log.annotation.Log;
import com.young.monitor.model.ApiIndex;
import com.young.monitor.model.ApiIndexStatSearch;
import com.young.monitor.service.IApiIndexService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * 接口统计
 * Created by Administrator on 2019/7/21.
 */
@Controller
@RequestMapping("/monitor/stat")
public class ApiStatController {

    /**
     * 监控指标服务
     */
    @Resource(name="apiIndexService")
    IApiIndexService apiIndexService;

    /**
     * 查询监控数据
     * @param apiIndexStatSearch
     * @param request
     * @return
     */
    @Log("API监控统计")
    @RequestMapping(value = "/getStat", method = {RequestMethod.GET, RequestMethod.POST})
    @ResponseBody
    public Object getStat(ApiIndexStatSearch apiIndexStatSearch, HttpServletRequest request) {
        List<ApiIndex> list = apiIndexService.getApiIndexStat(apiIndexStatSearch);
        return Result.buildSuccess(list);
    }
}
